<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p>这是一个H5文件</p>
    <hr>
    <button onclick="btnClick()">按钮</button>
    <div id="demo" style="height: 50px;width: 50px;border: 1px blue solid;"></div>
</body>
<script>
    function btnClick() {
        alert(new Date())
    }
    function $(element) {
        return new Base(element)
    }

    function Base(element) {
        this.style = function(key, value) {
            var dom = null;
            if (element.startsWith('#')) {
                dom = document.getElementById(element.substring(1));
            } else {
                dom = document.getElementsByClassName(element.substring(1));
            }
            dom.style[key] = value;
        }
    }

    $('#demo').style('background-color', 'red');
</script>
</html>